package com.mive.dao;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import java.util.concurrent.TimeUnit;

/**
 * @author Allen
 * @version 1.0.0
 * @createTime 2018-06-06 14:33
 * @description redis
 */
@Repository
public class RedisDao {
    private StringRedisTemplate template;

    public void setKey(String key, String value){
        ValueOperations<String, String> ops = template.opsForValue();
        ops.set( key, value ,30,TimeUnit.MINUTES);
    }

    public String getKey(String key){
        ValueOperations<String, String> ops = template.opsForValue();
        return ops.get( key );
    }
}
